home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / demo1.zoo / demo / plot / mgrplot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-24  |  2.6 KB  |  143 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: mgrplot.c,v 4.1 88/06/21 14:03:12 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/demo/plot/RCS/mgrplot.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/plot/RCS/mgrplot.c,v $$Revision: 4.1 $";
  12.  
  13. #include <stdio.h>
  14.  
  15. float deltx;
  16. float delty;
  17.  
  18. main(argc,argv)  char **argv; {
  19.     int std=1;
  20.     FILE *fin;
  21.  
  22.     ckmgrterm( *argv );
  23.  
  24.     while(argc-- > 1) {
  25.         if(*argv[1] == '-')
  26.             switch(argv[1][1]) {
  27.             case 'l':
  28.                 deltx = atoi(&argv[1][2]) - 1;
  29.                 break;
  30.             case 'w':
  31.                 delty = atoi(&argv[1][2]) - 1;
  32.                 break;
  33.             }
  34.  
  35.         else {
  36.             std = 0;
  37.             if ((fin = fopen(argv[1], "r")) == NULL) {
  38.                 fprintf(stderr, "can't open %s\n", argv[1]);
  39.                 exit(1);
  40.                 }
  41.             fplt(fin);
  42.             fclose(fin);
  43.             }
  44.         argv++;
  45.         }
  46.     if (std)
  47.         fplt( stdin );
  48.     exit(0);
  49.     }
  50.  
  51.  
  52. fplt(fin)  FILE *fin; {
  53.     int c;
  54.     char s[256];
  55.     int xi,yi,x0,y0,x1,y1,r,dx,n,i;
  56.     int pat[256];
  57.  
  58.     openpl();
  59.     while((c=getc(fin)) != EOF){
  60.         switch(c){
  61.         case 'm':
  62.             xi = getsi(fin);
  63.             yi = getsi(fin);
  64.             move(xi,yi);
  65.             break;
  66.         case 'l':
  67.             x0 = getsi(fin);
  68.             y0 = getsi(fin);
  69.             x1 = getsi(fin);
  70.             y1 = getsi(fin);
  71.             line(x0,y0,x1,y1);
  72.             break;
  73.         case 't':
  74.             getstr(s,fin);
  75.             label(s);
  76.             break;
  77.         case 'e':
  78.             erase();
  79.             break;
  80.         case 'p':
  81.             xi = getsi(fin);
  82.             yi = getsi(fin);
  83.             point(xi,yi);
  84.             break;
  85.         case 'n':
  86.             xi = getsi(fin);
  87.             yi = getsi(fin);
  88.             cont(xi,yi);
  89.             break;
  90.         case 's':
  91.             x0 = getsi(fin);
  92.             y0 = getsi(fin);
  93.             x1 = getsi(fin);
  94.             y1 = getsi(fin);
  95.             space(x0,y0,x1,y1);
  96.             break;
  97.         case 'a':
  98.             xi = getsi(fin);
  99.             yi = getsi(fin);
  100.             x0 = getsi(fin);
  101.             y0 = getsi(fin);
  102.             x1 = getsi(fin);
  103.             y1 = getsi(fin);
  104.             arc(xi,yi,x0,y0,x1,y1);
  105.             break;
  106.         case 'c':
  107.             xi = getsi(fin);
  108.             yi = getsi(fin);
  109.             r = getsi(fin);
  110.             circle(xi,yi,r);
  111.             break;
  112.         case 'f':
  113.             getstr(s,fin);
  114.             linemod(s);
  115.             break;
  116.         case 'd':
  117.             xi = getsi(fin);
  118.             yi = getsi(fin);
  119.             dx = getsi(fin);
  120.             n = getsi(fin);
  121.             for(i=0; i<n; i++)pat[i] = getsi(fin);
  122.             dot(xi,yi,dx,n,pat);
  123.             break;
  124.             }
  125.         }
  126.     closepl();
  127.     }
  128. getsi(fin)  FILE *fin; {    /* get an integer stored in 2 ascii bytes. */
  129.     short a, b;
  130.     if((b = getc(fin)) == EOF)
  131.         return(EOF);
  132.     if((a = getc(fin)) == EOF)
  133.         return(EOF);
  134.     a = a<<8;
  135.     return(a|b);
  136. }
  137. getstr(s,fin)  char *s;  FILE *fin; {
  138.     for( ; *s = getc(fin); s++)
  139.         if(*s == '\n')
  140.             break;
  141.     *s = '\0';
  142. }
  143.